package com.lz.controller;

import com.lz.domain.User;
import com.lz.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@Controller
public class Contro {
@Autowired
private UserService userService;
    @RequestMapping("/save00")
    @ResponseBody
    public User save00(Integer id  ) throws IOException {
        System.out.println(id);
        User user = userService.FindById(id);
////       获得容器
//        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContextMVC.xml");
//       //得到UserService对象
//        UserService bean = context.getBean(UserService.class);
//        User user = bean.FindById(id);
        System.out.println(user);
        //直接在页面控制台输出
        return user;
    }
}
